import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
//引入插件
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

import eslintPlugin from "vite-plugin-eslint";
export default defineConfig({
  plugins: [
    vue(),
    eslintPlugin({
      include: ["src/**/*.ts", "src/**/*.js", "src/**/*.vue", "src/*.ts", "src/*.js", "src/*.vue"],
    }),
    //配置插件
    AutoImport({
      eslintrc: {
        enabled: true,
      },
      resolvers: [ElementPlusResolver()],
      imports: ["vue", "vue-router"],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    // 配置路径别名
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
    // vite.config.ts
  },
  css: {
    // CSS 预处理器
    preprocessorOptions: {
      //define global scss variable
      scss: {
        javascriptEnabled: true,
        additionalData: `@use "@/styles/variables.scss" as *;`,
      },
    },
  },
  // 设置api代理
  server: {
    proxy: {
      "/api": "http://***", // 替换成你的域名
    },
    host: "0.0.0.0", //ip地址
    port: 8080, //端口号
    open: true, //启动后是否自动打开浏览器
  },
});
